Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modified to run captureSession.startRunning() on a background thread #378

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

hajunho
Copy link
Contributor

@hajunho hajunho commented Feb 9, 2024

It is more robust in thread management, ensuring that the start of the capture session does not block the main thread and that UI updates are performed on the main thread. Additionally, it carefully manages memory by using [weak self] to avoid retained cycles.

Copy link
Contributor

@AvdLee AvdLee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution!

@wetransferplatform
Copy link
Collaborator

wetransferplatform commented Feb 12, 2024

Fails
🚫

CIRectangleDetectorTests.testCorrectlyDetectsAndReturnsQuadilateral():
failed - Snapshot does not match reference.

@−
"/Users/vagrant/git/Tests/WeScanTests/Snapshots/CIRectangleDetectorTests/testCorrectlyDetectsAndReturnsQuadilateral.1.png"
@+
"/Users/vagrant/Library/Developer/CoreSimulator/Devices/B7E973E1-E2F0-4254-B50D-223B8780894F/data/tmp/CIRectangleDetectorTests/testCorrectlyDetectsAndReturnsQuadilateral.1.png"

To configure output for a custom diff tool, like Kaleidoscope:

SnapshotTesting.diffTool = "ksdiff"

Actual perceptual precision 0.69906247 is less than required 0.97

🚫

VisionRectangleDetectorTests.testCorrectlyDetectsAndReturnsQuadilateral():
failed - Snapshot does not match reference.

@−
"/Users/vagrant/git/Tests/WeScanTests/Snapshots/VisionRectangleDetectorTests/testCorrectlyDetectsAndReturnsQuadilateral.1.png"
@+
"/Users/vagrant/Library/Developer/CoreSimulator/Devices/B7E973E1-E2F0-4254-B50D-223B8780894F/data/tmp/VisionRectangleDetectorTests/testCorrectlyDetectsAndReturnsQuadilateral.1.png"

To configure output for a custom diff tool, like Kaleidoscope:

SnapshotTesting.diffTool = "ksdiff"

Newly-taken snapshot does not match reference.

Warnings
⚠️ 'gray' was deprecated in iOS 13.0: renamed to 'UIActivityIndicatorView.Style.medium'
⚠️ 'blackTranslucent' was deprecated in iOS 13.0: Use UIBarStyleBlack and set the translucent property to YES instead.
⚠️

'init(source:)' was deprecated in iOS 12.0: Core Image Kernel Language API deprecated. (Define CI_SILENCE_GL_DEPRECATION to silence these warnings)

⚠️ 'blackTranslucent' was deprecated in iOS 13.0: Use UIBarStyleBlack and set the translucent property to YES instead.
⚠️ 'isAutoStillImageStabilizationEnabled' was deprecated in iOS 13.0
⚠️ 'jpegPhotoDataRepresentation(forJPEGSampleBuffer:previewPhotoSampleBuffer:)' was deprecated in iOS 11.0
Messages
📖 WeScanTests: Executed 60 tests (2 failed, 0 retried, 0 skipped) in 13.227 seconds
📖 Slowest test: RectangleFeaturesFunnelTests/testAddAlternateImage() (4.692s)
📖 Slowest test: RectangleFeaturesFunnelTests/testAddPreviouslyDisplayedRect() (3.144s)
📖 Slowest test: RectangleFeaturesFunnelTests/testAddMinUnderThreshold() (3.025s)
📖

View more details on Bitrise

Code Coverage Report

Name Coverage
WeScan 37.24% ⚠️

SwiftLint found issues

Severity File Reason
Warning CaptureSessionManager.swift:271 The disabled 'function_parameter_count' rule should be re-enabled before the end of the file (blanket_disable_command)
Warning CaptureSessionManager.swift:147 Use shorthand syntax for optional binding (shorthand_optional_binding)
Warning CaptureSessionManager.swift:154 Use shorthand syntax for optional binding (shorthand_optional_binding)
Warning CaptureSessionManager.swift:165 Use shorthand syntax for optional binding (shorthand_optional_binding)

Generated by 🚫 Danger Swift against bbba45c

Copy link
Contributor Author

@hajunho hajunho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make an additional pull request reflecting BasThomas's review.

@hajunho
Copy link
Contributor Author

hajunho commented Feb 14, 2024

It looks unrelated #375 build issue is affecting Bitrise fail.

@hajunho
Copy link
Contributor Author

hajunho commented Feb 16, 2024

Actual perceptual precision 0.69906247 is less than required 0.97

Bitrise succeeded. Please advise, as there isn't a relationship between the threads and the precision of rectangle detection in the current code.

@AvdLee
Copy link
Contributor

AvdLee commented Feb 19, 2024

@hajunho are tests succeeding for you locally? Also, do you agree this test failure seems unrelated to your code changes?

@hajunho
Copy link
Contributor Author

hajunho commented Feb 20, 2024

@hajunho are tests succeeding for you locally? Also, do you agree this test failure seems unrelated to your code changes?

Yes, the tests went well locally. The test failures are not related to my code changes. However, errors at runtime should be taken seriously. It seems necessary to look closely at this problem and check if the environment settings or any recent changes have impacted it. Test benches are not easily created. So, I will search the code more and examine the parts needed for performance improvement. Could you provide any additional information or logs related to this test failure or the test bench? That information might help in identifying the cause of the problem. Additionally, I'd like to know if there's a way to visually inspect the two snapshots created by the test bench and then download the test result images for analysis with various tools to identify the differences.

@AvdLee
Copy link
Contributor

AvdLee commented Feb 23, 2024

@hajunho completely agree. I don't think we can access the test snapshots, so we really need to find a way to reproduce the test failure locally. My guess is that it results from a different Simulator used on CI.

CI runs using the following destination:

{ platform:iOS Simulator, id:B7E973E1-E2F0-4254-B50D-223B8780894F, OS:16.4, name:iPhone 14 Pro }

We've also not updated Xcode yet, so it's using Xcode 14.3.1 at this point.

Feel free to take up the challenge to solve the test in this PR! If not, let me know, and we'll merge this PR based on your local CI succession.

@hajunho
Copy link
Contributor Author

hajunho commented Feb 24, 2024

@hajunho completely agree. I don't think we can access the test snapshots, so we really need to find a way to reproduce the test failure locally. My guess is that it results from a different Simulator used on CI.

CI runs using the following destination:

{ platform:iOS Simulator, id:B7E973E1-E2F0-4254-B50D-223B8780894F, OS:16.4, name:iPhone 14 Pro }

We've also not updated Xcode yet, so it's using Xcode 14.3.1 at this point.

Feel free to take up the challenge to solve the test in this PR! If not, let me know, and we'll merge this PR based on your local CI succession.

Thank you for your insights. If I'm able to reproduce the issue and find a fix, I'll update the PR with the necessary changes.

@hajunho
Copy link
Contributor Author

hajunho commented Feb 24, 2024

@hajunho completely agree. I don't think we can access the test snapshots, so we really need to find a way to reproduce the test failure locally. My guess is that it results from a different Simulator used on CI.
CI runs using the following destination:

{ platform:iOS Simulator, id:B7E973E1-E2F0-4254-B50D-223B8780894F, OS:16.4, name:iPhone 14 Pro }

We've also not updated Xcode yet, so it's using Xcode 14.3.1 at this point.
Feel free to take up the challenge to solve the test in this PR! If not, let me know, and we'll merge this PR based on your local CI succession.

Thank you for your insights. If I'm able to reproduce the issue and find a fix, I'll update the PR with the necessary changes.

image The attached image shows the head minus my PR.

In the case of sub-items, there are a lot of fail cases, so it seems like there is confusion about fail for that item. Even if it is not my PR, the test fails in the existing main branch code. The same goes for iPhone SE~15pro. I'll have to spend some time exploring that test case. Can I leave this commit open until then?

@hajunho
Copy link
Contributor Author

hajunho commented Feb 24, 2024

@hajunho completely agree. I don't think we can access the test snapshots, so we really need to find a way to reproduce the test failure locally. My guess is that it results from a different Simulator used on CI.
CI runs using the following destination:

{ platform:iOS Simulator, id:B7E973E1-E2F0-4254-B50D-223B8780894F, OS:16.4, name:iPhone 14 Pro }

We've also not updated Xcode yet, so it's using Xcode 14.3.1 at this point.
Feel free to take up the challenge to solve the test in this PR! If not, let me know, and we'll merge this PR based on your local CI succession.

Thank you for your insights. If I'm able to reproduce the issue and find a fix, I'll update the PR with the necessary changes.

스크린샷 2024-02-24 오후 6 16 23

The precision numbers in the existing code match ideally, so there is no PR impact. It would be better to separate the test failure into another problem. Please merge when you are ready.

@AvdLee
Copy link
Contributor

AvdLee commented Feb 26, 2024

Thanks for diving deeper into the specifics! 🙏 We'll have a look at tests separately.

@AvdLee AvdLee merged commit cf918f7 into WeTransfer:master Feb 26, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants